It's all about the answers!

Ask a question

RTC 6.0.6.1 Failing to set Priority & Severity...other enums OK


Dave Evans (14812846) | asked Apr 18 '22, 2:13 p.m.
edited Apr 20 '22, 1:51 a.m. by Ralph Schoon (63.5k33646)

I am writing a tool that creates new work items with quite a few attributes. The POST is working fine and the work item is being created with no errors and all attributes are being set, except for priority and severity.


Priority and Severity are ignored... I have tried the following:

"oslc_cm:priority":{"rdf:resource":"<<resource url for literal>>"}
and 
"oslc_cmx:priority":{"rdf:resource":"<<resource url for literal>>"}

My headers are:
Content-Type: application/json
OSLC-Core-Version: 2.0

If I do a GET, the JSON does have additional items in the JSON... like this:
"oslc_cmx:priority":{"rdf:resource":"<<resource url for literal>>", "rdf:type":[{"rdf:resource":"https://rtc.domain/ccm/oslc/enumerations/_projectId/priority"},{"rdf:resource":"http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/Literal"}]}

I even tried including those parts that seem unnecessary, but the severity and priority are ignored.

Can someone send me a working example json that includes priority and severity and successfully creates a new work item and sets priority and severity?

Thanks,

Dave

Accepted answer


permanent link
Ralph Schoon (63.5k33646) | answered Apr 19 '22, 3:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 Dave,


this is the JSON body I sent and it created the work item just fine.

{
    "dcterms:title": "Work Item Created from JSON in Python.",
    "dcterms:description": "This is a work item linking to Jazz.net">https://jazz.net/\"">Jazz.net.",
    "rtc_cm:filedAgainst": "https://elm.example.com:9443/ccm/resource/itemOid/com.ibm.team.workitem.Category/_HWNLMFpnEeukW7cqqDjAuA",
    "oslc_cmx:priority": "https://elm.example.com:9443/ccm/oslc/enumerations/_8e5qfFpmEeukW7cqqDjAuA/priority/priority.literal.l11"
}
    
I used the creation factory and the allowed values for the attribute with Title "Priority" and value "High" to get the enumeration literal.

Dave Evans selected this answer as the correct answer

Comments
Ralph Schoon commented Apr 19 '22, 3:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

PS: at the moment I have no idea how to get the  "oslc_cmx:priority" from the  property definition: "oslc:propertyDefinition": {

                "rdf:resource": "http:\/\/open-services.net\/ns\/cm-x#priority"  }

In RDF XML, this is very easy, not sure how to do that in JSON.


Ralph Schoon commented Apr 19 '22, 8:32 a.m. | edited Apr 19 '22, 8:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If an RDF framework such as Python RDFLib is available, it is possible to create a mapping for the namespace prefix and the namespace.

    oslc_cmx = 'oslc_cmx'
    oslc_cmx_URI = 'http://open-services.net/ns/cm-x#'
    oslc_cmx_ns = Namespace(oslc_cmx_URI)

g = Graph()
    g.bind("rdf", RDF)
    g.bind("rdfs", RDFS)
    g.bind("dcterms", DCTERMS)
    g.bind(self.oslc_cmx, self.oslc_cmx_ns)

        .......

    definition = URIRef('http://open-services.net/ns/cm-x#priority')
    result = definition.n3(g.namespace_manager)


This allows to resolve the information 'oslc_cmx:priority'.

If there is no such framework it would be necessary to create a custom mapping  e.g. from 'http://open-services.net/ns/cm-x#' to 'oslc_cmx'


Dave Evans commented Apr 19 '22, 2:07 p.m.

Oh, interesting. For some reason I thought the rdf:resource property was required in the json. I left it out following your example and it WORKS! THANKS RALPH!


Interesting since the response json adds the "rdf:resource" part that isn't needed.


Ralph Schoon commented Apr 20 '22, 1:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I tried to share some of my experience in this blog series: https://rsjazz.wordpress.com/2021/09/29/using-the-ewm-rest-and-oslc-apis/ 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.